package LINE.comm.util;

import java.io.IOException;
import java.util.Properties;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

public class ResourceUtil {
	
	private static Properties props;
	
	private static void loadProperties() throws IOException
	{
		if(props != null) return;
		Resource resource = new ClassPathResource("/properties/resource.properties");
		props = PropertiesLoaderUtils.loadProperties(resource);
	}
	
	public static String getProperty(String key) throws IOException{
		loadProperties();
		return props.getProperty(key);
	}
	
	public static String getFileAttachPath()
	{
		try {
			return getProperty("com.file.path");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			return "";
		}
	}
	
	public static String getWebEditorImagePath()
	{
		try {
			return getProperty("com.webeditor.image.path");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			return "";
		}
	}
	
	public static String getImagePath()
	{
		try {
			return getProperty("com.image.path");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			return "";
		}
	}
	
	public static String getThumbnailFolder()
	{
		try {
			return getProperty("com.thumbnail.folder");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			return "";
		}
	}
	
	public static String getServiceCode(){
		try {
			return getProperty("com.service.code");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			return "";
		}
	}
	
	public static String getReportPath(){
		try {
			return getProperty("com.report.file.path");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			return "";
		}
	}
	
}
